//
//  WalletController.m
//  Japanese+
//
//  Created by ccdaguo on 15/10/31.
//  Copyright © 2015年 SSIC. All rights reserved.
//

#import "WalletViewController.h"
#import "VerificationViewController.h"
@interface WalletViewController ()<UITableViewDelegate,UITableViewDataSource>

@end

@implementation WalletViewController
{
    UILabel *_totalLabel;
    UILabel *_unexpiredLabel;
    UILabel *_expiredLabel;
    UILabel *_sevenLabel;
    UILabel *_thirtyLabel;
    UITableView *_tableView;
}



- (void)viewDidLoad {
    [super viewDidLoad];
    [self creatNavigationBarWithImage:nil title:@"我的钱包"];
     [self creatNavigationBarLeftItemWithLeftTitle:nil LeftImage:ECIMAGENAME(@"back_button.png")];
    // Do any additional setup after loading the view.

    [self creatTopView];
    [self creatTabelView];
}



- (void)leftBtnClick:(id)leftSender{
//    [self dismissModalViewControllerAnimated:YES];

    
    [self.navigationController popViewControllerAnimated:YES];
}


-(void)creatTopView
{
    UIView * topView = [[UIView alloc]initWithFrame:(CGRectMake(0, 64,ECSCREEN_W, 200))];
    [self.view addSubview:topView];
    topView.backgroundColor = [UIColor whiteColor];
    
    UIImageView * mainImageView = [[UIImageView alloc]initWithFrame:(CGRectMake(ECSCREEN_W/2 - 35, 10, 70, 70))];
    mainImageView.image = [UIImage imageNamed:@"wallet_top.png"];
    [topView addSubview:mainImageView];
    
    _totalLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 85, ECSCREEN_W, 15)];
//    myWalletLabel.backgroundColor = [UIColor redColor];
    _totalLabel.text = @"$8888.88";
    _totalLabel.font = [UIFont systemFontOfSize:15.f];
    _totalLabel.textAlignment = NSTextAlignmentCenter;
    [topView addSubview:_totalLabel];
    
    UILabel *totalNameLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 100, ECSCREEN_W, 15)];
    totalNameLabel.text = @"当前金额";
    totalNameLabel.font = [UIFont systemFontOfSize:10.f];
    totalNameLabel.textAlignment = NSTextAlignmentCenter;
    [topView addSubview:totalNameLabel];
    
    
    
    UIImageView *detailImage = [[UIImageView alloc] initWithFrame:CGRectMake(20, 120, ECSCREEN_W - 40, 50)];
    detailImage.image = ECIMAGENAME(@"wallet_money.png");
    [topView addSubview:detailImage];
    
    
//    UILabel *unexpired = [[UILabel alloc] initWithFrame:CGRectMake(0, 5, detailImage.frame.size.width/2, 20)];
//    unexpired.text = @"未消耗课时金额";
//    unexpired.textColor = ECCOLOR(255, 255, 255, 1);
//    unexpired.font = [UIFont systemFontOfSize:13.f];
//    unexpired.textAlignment = NSTextAlignmentCenter;
//    [detailImage addSubview:unexpired];
    
    
    _unexpiredLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 28, detailImage.frame.size.width/2, 20)];
    _unexpiredLabel.text = @"￥2000";
    _unexpiredLabel.textColor = ECCOLOR(255, 255, 255, 1);
    _unexpiredLabel.font = [UIFont systemFontOfSize:13.f];
    _unexpiredLabel.textAlignment = NSTextAlignmentCenter;
    [detailImage addSubview:_unexpiredLabel];
    
//    UILabel *expired = [[UILabel alloc] initWithFrame:CGRectMake(detailImage.frame.size.width/2, 5, detailImage.frame.size.width/2, 20)];
//    expired.text = @"累积计入";
//    expired.textColor = ECCOLOR(255, 255, 255, 1);
//    expired.font = [UIFont systemFontOfSize:13.f];
//    expired.textAlignment = NSTextAlignmentCenter;
//    [detailImage addSubview:expired];
    
    
    _expiredLabel = [[UILabel alloc] initWithFrame:CGRectMake(detailImage.frame.size.width/2, 28, detailImage.frame.size.width/2, 20)];
    _expiredLabel.text = @"￥2432";
    _expiredLabel.textColor = ECCOLOR(255, 255, 255, 1);
    _expiredLabel.textAlignment = NSTextAlignmentCenter;
    _expiredLabel.font = [UIFont systemFontOfSize:13.f];
    [detailImage addSubview:_expiredLabel];
    
    UILabel *seven = [[UILabel alloc] initWithFrame:CGRectMake(20, 175, 60, 20)];
    seven.text = @"近7日收入";
    seven.textColor = [UIColor lightGrayColor];
    seven.font = [UIFont systemFontOfSize:11.f];
    [topView addSubview:seven];
    
    
    _sevenLabel = [[UILabel alloc] initWithFrame:CGRectMake(85, 175, ECSCREEN_W/2 - 85, 20)];
    _sevenLabel.text = @"￥123";
    _sevenLabel.font = [UIFont systemFontOfSize:11.f];
    [topView addSubview:_sevenLabel];
    
    UILabel *thirty = [[UILabel alloc] initWithFrame:CGRectMake(ECSCREEN_W/2 + 20, 175, 60, 20)];
    thirty.text = @"近30日收入";
    thirty.textColor = [UIColor lightGrayColor];
    thirty.font = [UIFont systemFontOfSize:11.f];
    [topView addSubview:thirty];
    
    
    _thirtyLabel = [[UILabel alloc] initWithFrame:CGRectMake(ECSCREEN_W/2 + 85, 175, ECSCREEN_W/2 - 85, 20)];
    _thirtyLabel.text = @"￥123";
    _thirtyLabel.font = [UIFont systemFontOfSize:11.f];
    [topView addSubview:_thirtyLabel];
}

- (void)creatTabelView{
    _tableView = [[UITableView alloc]initWithFrame:(CGRectMake(0, 64 + 200 , ECSCREEN_W, ECSCREEN_H - 64 - 200)) style:(UITableViewStylePlain)];
    
    _tableView.delegate = self;
    _tableView.dataSource = self;
    _tableView.scrollEnabled = NO;
    
    _tableView.tableFooterView = [[UIView alloc]init];
    
    if ([_tableView respondsToSelector:@selector(setSeparatorInset:)]) {
        [_tableView setSeparatorInset:UIEdgeInsetsZero];
    }
    if ([_tableView respondsToSelector:@selector(setLayoutMargins:)]) {
        [_tableView setLayoutMargins:UIEdgeInsetsZero];
    }
    
    [self.view addSubview:_tableView];
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{

    return 1;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 2;
}


- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 5.f;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ECSCREEN_W, 5)];
    view.backgroundColor = BG_COLOR;
    return view;
}



- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    static NSString *reuseIdentifier = @"walletCell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifier];
    if (nil == cell) {
        
        cell = [[UITableViewCell alloc]initWithStyle:(UITableViewCellStyleDefault) reuseIdentifier:reuseIdentifier];

        if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
            [cell setSeparatorInset:UIEdgeInsetsZero];
        }
        if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
            [cell setLayoutMargins:UIEdgeInsetsZero];
        }
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    
    
    if (indexPath.section == 0) {
        cell.textLabel.text = @"收支明细";
        cell.textLabel.font = [UIFont systemFontOfSize:13.f];
        cell.textLabel.textColor = ECCOLOR(0, 0, 0, 1);
    }else if (indexPath.section == 1){
        cell.textLabel.text = @"绑定账号";
        cell.textLabel.font = [UIFont systemFontOfSize:13.f];
        cell.textLabel.textColor = ECCOLOR(0, 0, 0, 1);
    }
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 44.f;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 1) {
        VerificationViewController *verificationVC = [[VerificationViewController alloc]init];
        [self.navigationController pushViewController:verificationVC animated:YES];
    }
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
